import { eLayoutType, RoutesService } from '@abp/ng.core';
import { APP_INITIALIZER } from '@angular/core';
import { eThemeSharedRouteNames } from '@abp/ng.theme.shared';

export const BASICARCHIVES_ROUTE_PROVIDERS = [
  { provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService], multi: true },
];

export function configureRoutes(routes: RoutesService) {
  return () => {
    var basicRoute = routes.find(x => x.name == 'BasicArchives::Menu:BasicArchives.ArchivesManagement');
    if (!basicRoute) {
      routes.add([
        {
          path: undefined,
          name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
          layout: eLayoutType.application,
          order: 80,
          iconClass: 'database',
        },
      ]);
    }

    //人员管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Staff',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'team',
      },
      {
        path: '/basic-archives/staff/department-detail',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Staff.Department',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Staff',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Staff.Department',
        iconClass: 'apartment',
      },
      {
        path: '/basic-archives/staff/operator-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Staff.Operator',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Staff',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Staff.Operator',
        iconClass: 'user',
      },
    ]);

    //料品管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'shopping',
      },
      {
        path: '/basic-archives/item-masters/item-category-detail',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.ItemCategory',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.ItemCategory',
        iconClass: 'tags',
      },
      {
        path: '/basic-archives/item-masters/unit-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.Unit',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.Unit',
        iconClass: 'calculator',
      },
      {
        path: '/basic-archives/item-masters/unit-group-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.UnitGroup',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.UnitGroup',
        iconClass: 'cluster',
      },
      {
        path: '/basic-archives/item-masters/item-master-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.ItemMaster',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.ItemMaster',
        iconClass: 'file-text',
      },
      // {
      //   path: '/basic-archives/item-masters/bill-of-materials-list',
      //   name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.BillOfMaterials',
      //   parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
      //   requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.BillOfMaterials',
      //   iconClass: 'bars',
      // },
      {
        path: '/basic-archives/item-masters/bom-master-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters.BomMaster',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ItemMasters',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ItemMasters.BomMaster',
        iconClass: 'cluster',
      },
    ]);

    //客户管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Customers',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'solution',
      },
      {
        path: '/basic-archives/customers/customer-type-detail',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Customers.CustomerType',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Customers',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Customers.CustomerType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/customers/customer-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Customers.Customer',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Customers',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Customers.Customer',
        iconClass: 'user',
      },
    ]);

    //供应商管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Suppliers',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'shop',
      },
      {
        path: '/basic-archives/suppliers/supplier-type-detail',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Suppliers.SupplierType',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Suppliers',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Suppliers.SupplierType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/suppliers/supplier-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Suppliers.Supplier',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Suppliers',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Suppliers.Supplier',
        iconClass: 'shop',
      },
    ]);

    //仓储管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Storage',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'inbox',
      },
      {
        path: '/basic-archives/storage/warehouse-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Storage.Warehouse',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.Storage',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.Storage.Warehouse',
        iconClass: 'home',
      },
    ]);

    //生产单元
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ProductionUnit',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement',
        layout: eLayoutType.application,
        iconClass: 'setting',
      },
      {
        path: '/basic-archives/production-unit/work-center-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ProductionUnit.WorkCenter',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ProductionUnit',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ProductionUnit.WorkCenter',
        iconClass: 'tool',
      },
      {
        path: '/basic-archives/production-unit/equipment-list',
        name: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ProductionUnit.Equipment',
        parentName: 'BasicArchives::Menu:BasicArchives.ArchivesManagement.ProductionUnit',
        requiredPolicy: 'Menus.BasicArchives.ArchivesManagement.ProductionUnit.Equipment',
        iconClass: 'setting',
      },
    ]);

    //销售管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement',
        layout: eLayoutType.application,
        order: 40,
        iconClass: 'shopping-cart',
      },
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales',
        parentName: 'BasicArchives::Menu:BasicArchives.SalesManagement',
        layout: eLayoutType.application,
        iconClass: 'shopping',
      },
      {
        path: '/basic-archives/sales/sale-order-type-list',
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales.SaleOrderType',
        parentName: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales',
        requiredPolicy: 'Menus.BasicArchives.SalesManagement.Sales.SaleOrderType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/sales/sale-order-list',
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales.SaleOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales',
        requiredPolicy: 'Menus.BasicArchives.SalesManagement.Sales.SaleOrder',
        iconClass: 'shopping-cart',
      },
      {
        path: '/basic-archives/sales/intent-order-type-list',
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales.IntentOrderType',
        parentName: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales',
        requiredPolicy: 'Menus.BasicArchives.SalesManagement.Sales.IntentOrderType',
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/sales/intent-order-list',
        name: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales.IntentOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.SalesManagement.Sales',
        requiredPolicy: 'Menus.BasicArchives.SalesManagement.Sales.IntentOrder',
        iconClass: 'file-done',
      },
    ]);

    //采购管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement',
        layout: eLayoutType.application,
        order: 50,
        iconClass: 'shopping',
      },
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement',
        layout: eLayoutType.application,
        iconClass: 'shopping',
      },
      {
        path: '/basic-archives/procurements/purchase-order-type-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements.PurchaseOrderType',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Procurements.PurchaseOrderType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/procurements/purchase-order-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements.PurchaseOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Procurements.PurchaseOrder',
        iconClass: 'shopping-cart',
      },
      {
        path: '/basic-archives/procurements/purchase-requisition-type-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements.PurchaseRequisitionType',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Procurements.PurchaseRequisitionType',
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/procurements/purchase-requisition-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements.PurchaseRequisition',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Procurements',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Procurements.PurchaseRequisition',
        iconClass: 'file-done',
      },
    ]);

    //ASN管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Asns',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement',
        layout: eLayoutType.application,
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/asns/asn-type-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Asns.AsnType',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Asns',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Asns.AsnType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/asns/asn-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Asns.Asn',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Asns',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Asns.Asn',
        iconClass: 'file-text',
      },
    ]);

    //收货管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement',
        layout: eLayoutType.application,
        iconClass: 'inbox',
      },
      {
        path: '/basic-archives/receipt/receivement-type-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt.ReceivementType',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Receipt.ReceivementType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/receipt/receivement-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt.Receivement',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Receipt.Receivement',
        iconClass: 'inbox',
      },
      {
        path: '/basic-archives/receipt/receivement-order-list',
        name: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt.ReceivementOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.PurchasingManagement.Receipt',
        requiredPolicy: 'Menus.BasicArchives.PurchasingManagement.Receipt.ReceivementOrder',
        iconClass: 'file-text',
      },
    ]);

    //生产管理
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement',
        layout: eLayoutType.application,
        order: 60,
        iconClass: 'tool',
      },
      {
        path: undefined,
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement',
        layout: eLayoutType.application,
        iconClass: 'setting',
      },
      {
        path: '/basic-archives/production/plan-order-type-list',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.PlanOrderType',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.PlanOrderType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/production/plan-order-list',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.PlanOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.PlanOrder',
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/production/production-order-type-list',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.ProductionOrderType',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.ProductionOrderType',
        iconClass: 'tag',
      },
      {
        path: '/basic-archives/production/production-order-list',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.ProductionOrder',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.ProductionOrder',
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/production/production-platform',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.ProductionPlatform',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.ProductionPlatform',
        iconClass: 'file-text',
      },
      {
        path: '/basic-archives/production/material-management-platform',
        name: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production.MaterialManagementPlatform',
        parentName: 'BasicArchives::Menu:BasicArchives.ProductionManagement.Production',
        requiredPolicy: 'Menus.BasicArchives.ProductionManagement.Production.MaterialManagementPlatform',
        iconClass: 'dashboard',
      },
    ]);

    //数据同步
    routes.add([
      {
        path: undefined,
        name: 'BasicArchives::Menu:Administration.Sync',
        parentName: eThemeSharedRouteNames.Administration,
        layout: eLayoutType.application,
        iconClass: 'reload',
        order: 3,
      },
      {
        path: '/basic-archives/sync/archives-sync',
        name: 'BasicArchives::Menu:Administration.Sync.ArchivesSync',
        parentName: 'BasicArchives::Menu:Administration.Sync',
        requiredPolicy: 'Menus.Administration.Sync.ArchivesSync',
        layout: eLayoutType.application,
        iconClass: 'book',
      },
      {
        path: '/basic-archives/sync/document-sync',
        name: 'BasicArchives::Menu:Administration.Sync.DocumentSync',
        parentName: 'BasicArchives::Menu:Administration.Sync',
        requiredPolicy: 'Menus.Administration.Sync.DocumentSync',
        layout: eLayoutType.application,
        iconClass: 'copy',
      },
    ]);
  };
}
